package copyengine.dataLayer.rpc.moudle.codeConvert
{
	import copyengine.utils.debug.CELog;

	import flash.utils.ByteArray;

	public class CECustomRpcCodeConvert implements ICERpcCodeConvertModule
	{
		//目前版本用PHP做后端无法自定义RPC，一切由netcenection代理
		public function logicLayerDataToTransferLayerData(_logicLayerDataArray:Array, _requestCount:int):*
		{
			throw new Error("Not Implements")
		}

		public function transferLayerDataToLogicLayerData(_transferLayerData:*):Array
		{
			throw new Error("Not Implements");
		}

//		/**
//		 *secretKey will initialze by first request result ,
//		 * first requst server will pass the secret back , then after first request each reqeust
//		 * need take the serrectKey with , server will use this key to judge is user open two brownser
//		 * or not
//		 */
//		private var secretKey:String;
//
//		/**
//		 *define which protoco that current system use . this Version number will hardcode.
//		 */
//		private var protocolVersion:String;
//
//		public function CECustomRpcCodeConvert(_protocolVersion:String)
//		{
//			protocolVersion = _protocolVersion;
//			secretKey = "not initialze";
//		}
//
//		public function setSecretKey(_key:String):void
//		{
//			secretKey = _key;
//		}
//
//		/**
//		 * Data structure
//		 * [
//		 * 		header[0] : {version : xxx , sk(secretkey) :xxx , st(requestCount):xxx}
//		 * 		data[1]: [{obj} , {method:xxx , param1:xxx , param2:xxx}, {obj}]
//		 * ]
//		 */
//		public function gameDataToTransferLayerData(_objArray:Array, _requestCount:int):ByteArray
//		{
//			var byte:ByteArray = new ByteArray();
//
//			var header:Object = {version: protocolVersion, sk: secretKey, st: _requestCount};
//
//			byte.writeObject([header, _objArray]);
//
//			byte.compress();
//
//			return byte;
//		}
//
//		/**
//		 * Data structure
//		 *
//		 * [
//		 * 		header[0] : {errCode[int](globalError , receive this no need to deal other data):xxx}
//		 * 		data[1] : [{obj} , {method:xxx, retCode(define current request state ,successed?faild?alreadysend?):xxx , param1:xxx , param2:xxx}]
//		 * ]
//		 */
//		public function transferLayerDataToGameData(_byteArray:ByteArray):Array
//		{
//			_byteArray.uncompress();
//
//			var result:Array = _byteArray.readObject() as Array;
//
//			//ErrorSucation Two: receive global Error
//			if (result[0]["errCode"] > 0)
//			{
//				CELog.err("ReceiveData found globalError request data reject read");
//				return null;
//			}
//			return result[1];
//		}

	}
}
